<template>
  <div class="app-container">
    <div class="queryform">
      <el-form
        :model="form"
        ref="form"
        label-width="97px"
        label-position="right"
      >
        <el-form-item label="用户名:" prop="userCode">
          <el-input
            v-model.trim="form.userCode"
            maxlength="128"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item label="用户得分:" prop="trustScore">
          <el-input
            v-model.trim="form.trustScore"
            maxlength="128"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item label="用户等级:" prop="trustLevel">
          <el-select v-model="form.trustLevel">
            <el-option
              v-for="item in trustLevelList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="refresh">查询</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="mod-result-table">
      <HTable
        ref="table"
        :tableData="tableData"
        :columnConfigs="columnConfigs"
        :selectable="false"
        orderable
        v-loading="loading"
        :pages="pagination"
        @page-change="handlePageChange"
        @size-change="handleSizeChange"
      >
        <template slot-scope="{ row }">
          <template v-if="row.name == 'action'">
            <el-button
              type="text"
              size="small"
              icon="el-icon-document"
              @click="seeDeatil(row.row)"
              >详情</el-button
            >
          </template>
          <template v-else-if="row.name == 'trustLevel'">
            {{ $getOptionLabel(row.row.trustLevel, trustLevelList) }}
          </template>
        </template>
      </HTable>
    </div>
    <div class="vpnform">
      <detail ref="detailDialog" :detailVisible.sync="detailVisible"></detail>
    </div>
  </div>
</template>

<script>
import table from "@/mixins/commontable";
import detail from "./detail.vue";
import { columnConfigs } from "./columnConfigs.js";
import { getList } from "@/api/yybl/userInfo";
import { mapState } from "vuex";
export default {
  components: {
    detail,
  },
  mixins: [table], //表格的混入，主要包括表格上通用的方法和数据，比如查询，重置，分页这些功能
  props: {},
  data() {
    return {
      columnConfigs,
      detailVisible: false,
      editFlag: false,
      curRow: {},
      form: {
        userName: "",
        userCode: "",
        trustScore: "",
        trustLevel: "",
      },
    };
  },
  watch: {},
  computed: {
    ...mapState("common", ["trustLevelList"]), //函数中第一个是模块名称，第二个是模块中的数组
  },
  methods: {
    formatTrancy(val) {
      let a = Number(val);
      return Math.round(a * 100) + "%";
    },
    seeDeatil(row) {
      this.detailVisible = true;
      this.$nextTick(() => {
        this.$refs.detailDialog.detail(row);
      });
    },
    handleClose() {
      this.detailVisible = false;
    },
    getparams() {
      const { userCode, trustScore, trustLevel } = this.form;
      return { userCode, trustScore, trustLevel };
    },
    refresh() {
      let params = this.getparams();
      this.getlists(getList, params);
      setTimeout(() => {
        console.log(this.tableData);
      });
      // this.tableData = [
      //   {
      //     userName: "张三",
      //     nickName: "zhangsan",
      //     fen: "60分",
      //     level: "高",
      //     changjing: "4A登录",
      //     senceList: [
      //       {
      //         senceName: "张三",
      //         senceRule: "zhangsan",
      //         koufen: "60",
      //         biaodashi: "高",
      //       },
      //     ],
      //   },
      // ];
    },
    resetForm() {
      this.$nextTick(() => {
        this.$refs["form"].resetFields();
        this.refresh();
      });
    },
  },
  created() {
    this.refresh();
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__content {
  .el-date-editor.el-input {
    width: 100%;
  }
}
::v-deep .el-button {
  .el-icon-edit + span {
    margin-left: 0px;
  }
  .el-icon-delete + span {
    margin-left: 0px;
  }
}
::v-deep .el-dialog {
  min-width: 640px;
  .el-dialog__header {
    border-bottom: 1px solid #e8e8e8;
  }
  .el-dialog__footer {
    border-top: 1px solid #e8e8e8;
  }
}
.addDialog {
  .el-dialog {
    min-width: 640px;
  }

  .el-form {
    .el-form-item.slider {
      width: 100%;
    }
  }
}
.queryform {
  ::v-deep .el-form {
    display: flex;
    flex-wrap: wrap;

    .el-form-item {
      max-width: 25%;
      flex-grow: 1;
      flex-shrink: 1;
      flex-basis: 25%;
    }

    // .el-form-item:nth-child(7) {
    //   max-width: 100%;
    //   flex-basis: 100%;
    //   display: flex;
    //   justify-content: end;
    // }
  }
}
</style>
